//========================================================================
//  SE5 Empire Main - Cue Cappa - Captain Kwok's Balance Mod v125+
//========================================================================

#include Script_AI_GlobalConstants.txt
#include Script_AI_GlobalVariables.txt

//------------------------------------------------------------------------
// Global Constants
//------------------------------------------------------------------------

//------------------------------------------------------------------------
// Global Variables
//------------------------------------------------------------------------

//------------------------------------------------------------------------
// Forward Declarations
//------------------------------------------------------------------------
deffunc

function Set_Race_Script_Values returns boolean
params
end

function Set_Race_Default_Settings returns boolean
params
end

function Set_Race_Vehicle_Amounts returns boolean
params
end

function Set_Race_Research_Spending returns boolean
params
end

function Set_Race_Research_Areas returns boolean
params
end

function Set_Race_Weapon_Choices returns boolean
params
  vehicle_type:              string
  vehicle_tonnage:           long
  design_type:               string
end

function Set_Race_Overall_Spending_Percentages returns boolean
params
end

function Set_Race_Strategy_Preferences returns boolean
params
end

function Set_Race_Political_Settings returns boolean
params
end

enddeffunc

//------------------------------------------------------------------------
// Includes
//------------------------------------------------------------------------

#include Script_AI_GlobalFunctions.txt
#include Script_AI_GlobalSettings.txt
#include Script_AI_Lists.txt
#include Script_AI_StateChange.txt
#include Script_AI_ColonyType.txt
#include Script_AI_Construction.txt
#include Script_AI_DesignCreation.txt
#include Script_AI_EnemyAnalysis.txt
#include Script_AI_PerformanceAnalysis.txt
#include Script_AI_Intelligence.txt
#include Script_AI_Orders_Planets.txt
#include Script_AI_Orders_Ships.txt
#include Script_AI_Restricted_SolarSystems.txt
#include Script_AI_Politics.txt
#include Script_AI_Research.txt

//------------------------------------------------------------------------
// Main
//------------------------------------------------------------------------
function Main returns boolean
begin

  // Base values for this AI
  call Set_Game_Settings()
  call Set_Race_Script_Values()

  // Set facility and vehicle IDs
  call Set_Facility_Id()
  call Set_Vehicle_Sizes()

  // Generate lists for AI use
  call AI_Generate_Lists()

  // Analyze enemies
  call AI_EnemyAnalysis()
  call AI_PerformanceAnalysis()

  // Compute any state changes
  call AI_StateChange()

  // Set race preferences
  call Set_Race_Default_Settings()
  call Set_Race_Point_Modifiers()
  call Set_Race_Resource_Modifiers()
  call Set_Race_Vehicle_Amounts()
  call Set_Race_Design_Types()
  call Set_Race_Research_Spending()
  call Set_Race_Research_Areas()
  call Set_Race_Overall_Spending_Percentages()
  call Set_Race_Strategy_Preferences()
  call Set_Race_Political_Settings()

  // Execute AI Controls
  call AI_SetColonyTypes()
  call AI_Restricted_SolarSystems()
  call AI_DesignCreation()
  call AI_Politics()
  call AI_Research()
  call AI_Intelligence()
  call AI_Orders_Planets()
  call AI_Orders_Ships()
  call AI_Construction()

end

//------------------------------------------------------------------------
// Main_Create_Specific_Design (Called externally in Create Design window)
//------------------------------------------------------------------------
function Main_Create_Specific_Design returns boolean
params
  design_id:                 long
  retval:                    boolean
begin

  call Set_Vehicle_Sizes()
  call Set_Race_Research_Areas()
  call Set_Race_Design_Types()
  set retval := Create_Specific_Design(design_id)

  return retval
end

//------------------------------------------------------------------------
// Set_Race_Script_Values
//------------------------------------------------------------------------
function Set_Race_Script_Values returns boolean
begin

  // Cue Cappa AI Category
  set lng_AI_Categorization                                          := AI_CATEGORY_NEUTRAL
  set lng_AI_Secondary_Categorization                                := AI_CATEGORY_PEACEFUL
  set lng_AI_Villain_Status                                          := AI_CATEGORY_NOT_VILLAIN

  // Consider a category change for the game (5% chance)
  if (sys_long_Game_Date = (Sys_Get_Game_Start_Date() + 1)) then
    if (Sys_Get_Random_Long(1, 20) = 1) then
      // Use our secondary category
      call Sys_Set_AI_Storage_Long(sys_long_Player_ID, 1, 12, lng_AI_Secondary_Categorization)
    else
      call Sys_Set_AI_Storage_Long(sys_long_Player_ID, 1, 12, 0)
    endif
    // We're never a villain
    call Sys_Set_AI_Storage_Long(sys_long_Player_ID, 1, 13, lng_AI_Villain_Status)
  endif

  // Check to see if we're using our secondary category, if yes, then set our category to our secondary category
  if (Sys_Get_AI_Storage_Long(sys_long_Player_ID, 1, 12) > 0) then
    set lng_AI_Categorization := lng_AI_Secondary_Categorization
    // Debug text
    call Sys_Debug_Print("Enemy Analysis", "  - Using Secondary AI Category (" + Sys_Convert_Long_To_String(lng_AI_Secondary_Categorization) + ")")
  endif

  // Check to see if we're a game villain
  if (Sys_Get_AI_Storage_Long(sys_long_Player_ID, 1, 13) > 0) then
    set lng_AI_Villain_Status := AI_CATEGORY_VILLAIN
    // Debug text
    call Sys_Debug_Print("Enemy Analysis", "  - Are a Game Villain!")
  endif

  // Cue Cappa racial traits
  set bool_Race_Uses_Crystalline_Tech                                := FALSE
  set bool_Race_Uses_Interdimensional_Tech                           := FALSE
  set bool_Race_Uses_Organic_Tech                                    := FALSE
  set bool_Race_Uses_Psychic_Tech                                    := TRUE
  set bool_Race_Uses_Temporal_Tech                                   := FALSE
  set bool_Race_Uses_Religious_Tech                                  := FALSE

  // Cue Cappa starting strategies
  set lng_AI_Empire_Strategy                                         := AI_EMPIRE_STRATEGY_DEFEND
  set lng_AI_Empire_Design_Strategy                                  := AI_DESIGN_STRATEGY_DIRECTFIRE

  return TRUE
end

//------------------------------------------------------------------------
// Set_Race_Default_Settings
//------------------------------------------------------------------------
function Set_Race_Default_Settings returns boolean
begin

  // Cue Cappa design type usage
  set bool_Race_Uses_Mines                                           := TRUE
  set bool_Race_Uses_Remote_Mines                                    := TRUE
  set bool_Race_Uses_Fighters                                        := TRUE
  set bool_Race_Uses_Remote_Fighters                                 := FALSE
  set bool_Race_Uses_Satellites                                      := TRUE
  set bool_Race_Uses_Remote_Satellites                               := FALSE
  set bool_Race_Uses_Troops                                          := TRUE
  set bool_Race_Uses_Weapon_Platforms                                := TRUE
  set bool_Race_Uses_Drones                                          := TRUE
  set bool_Race_Uses_Remote_Drones                                   := FALSE
  set bool_Race_Uses_Explorer_Ships                                  := TRUE
  set bool_Race_Uses_Scout_Ships                                     := bool_Race_Is_Not_Alone
  set bool_Race_Uses_Patrol_Ships                                    := bool_Race_Is_Not_Alone
  set bool_Race_Uses_Seeker_Ships                                    := FALSE
  set bool_Race_Uses_Kamikaze_Ships                                  := FALSE
  set bool_Race_Uses_Plague_Ships                                    := FALSE
  set bool_Race_Uses_Boarding_Ships                                  := FALSE
  set bool_Race_Uses_Bombardment_Ships                               := FALSE
  set bool_Race_Uses_Remote_Mining_Ships                             := TRUE
  set bool_Race_Uses_Remote_Farming_Ships                            := TRUE
  set bool_Race_Uses_Remote_Refining_Ships                           := TRUE
  set bool_Race_Uses_Stellar_Manipulation_Ships                      := TRUE
  set bool_Race_Uses_Evil_Stellar_Manipulation_Ships                 := TRUE

  // Cue Cappa component preferences
  set bool_Race_Uses_Normal_Armor                                    := TRUE
  set bool_Race_Uses_Normal_Shields                                  := TRUE
  set bool_Race_Uses_Cloaking_Devices                                := not bool_Enemy_Uses_Advanced_Sensors
  set bool_Race_Uses_Master_Computers                                := FALSE
  set bool_Race_Uses_Combat_Best_Experience                          := TRUE
  // Ratio of launchers on carriers (30 to 80)
  set lng_AI_Design_Ratio_Launchers                                  := 50

  // Cue Cappa unit percentages for colonies
  set lng_AI_Pct_Troops_For_Colonies                                 := 80
  set lng_AI_Pct_Fighters_For_Colonies                               := 100
  set lng_AI_Pct_Satellites_For_Colonies                             := 100
  set lng_AI_Pct_Mines_For_Colonies                                  := 20
  set lng_AI_Pct_Drones_For_Colonies                                 := 100

  // Cue Cappa unit group sizes
  set lng_AI_Min_Fighter_Group_Size                                  := 20
  set lng_AI_Min_Satellite_Group_Size                                := 5
  set lng_AI_Min_Drone_Group_Size                                    := 5
  set lng_AI_Min_Mine_Group_Size                                     := 20

  // Cue Cappa scrap values
  set lng_Ship_Obsolete_Time_To_Scrap                                := 80
  set lng_Max_Ships_To_Scrap                                         := 2
  set lng_Unit_Obsolete_Time_To_Scrap                                := 80
  set lng_Max_Units_To_Scrap                                         := 120

  // Cue Cappa attack/defense preferences
  set lng_Max_Attack_Systems                                         := 2
  set lng_Max_Defense_Systems                                        := 4

  // Cue Cappa Fleet preferences
  set lng_Percent_Of_Attack_Ships_To_Use_For_Fleets                  := 90
  set lng_Pct_Fleets_For_Attack                                      := 50
  set lng_Pct_Fleets_For_Defense                                     := 50
  set lng_Pct_Ships_For_Attack_Fleets                                := 60
  set lng_Pct_Ships_For_Defense_Fleets                               := 40
  set lng_AI_Fleet_Size                                              := FLEET_SIZE_MEDIUM

  return TRUE
end

//------------------------------------------------------------------------
// Set_Race_Vehicle_Amounts
//------------------------------------------------------------------------
function Set_Race_Vehicle_Amounts returns boolean
params
vars
  size_dist_mod:             long
  size_mod:                  long
  tech_mod:                  long
  empire_mod:                long
  attack_mod:                long
  defense_mod:               long
  seeker_mod:                long
  baseship_mod:              long
  explore_mod:               long
  scout_mod:                 long
  patrol_mod:                long
  pd_mod:                    long
  kamikaze_mod:              long
  carrier_mod:               long
  base_mod:                  long
  troop_mod:                 long
  fighter_mod:               long
  wp_mod:                    long
  sat_mod:                   long
  mine_mod:                  long
  drone_mod:                 long
  minerals_mod:              long
  organics_mod:              long
  radioactives_mod:          long
begin


  // Cue Cappa ship size distribution modifiers
  if Is_Vehicle_Size_Available("Light Cruiser") then
    if (bool_AI_Design_Preference_Small) then
      set size_dist_mod := size_dist_mod + 10
      set size_mod := size_mod + 8
    endif
    if (bool_Enemy_Ships_Are_Faster) then
      set size_dist_mod := size_dist_mod + 10
      set size_mod := size_mod + 4
    endif
    // Cue Cappa ship size distribution
    set lng_Pct_Small_Ships := 20 + Sys_Divide_Long(size_dist_mod, 2)
    set lng_Pct_Medium_Ships := 40 + Sys_Divide_Long(size_dist_mod, 2)
    set lng_Pct_Large_Ships := 40 - size_dist_mod
  else
    if Is_Vehicle_Size_Available("Destroyer") then
      set lng_Pct_Small_Ships := 50 + size_dist_mod
      set lng_Pct_Medium_Ships := 50 - size_dist_mod
    else
      set lng_Pct_Small_Ships := 100
    endif
  endif

  // Cue Cappa Carrier size distribution
  if Is_Vehicle_Size_Available("Heavy Carrier") then
    set lng_Pct_Small_Carriers := 0
    set lng_Pct_Medium_Carriers := 0
    set lng_Pct_Large_Carriers := 100
  else
    if Is_Vehicle_Size_Available("Carrier") then
      set lng_Pct_Small_Carriers := 0
      set lng_Pct_Medium_Carriers := 100
    else
      set lng_Pct_Small_Carriers := 100
    endif
  endif

  // Cue Cappa Base size distribution
  if Is_Vehicle_Size_Available("Starbase") then
    set lng_Pct_Small_Bases := 20
    set lng_Pct_Large_Bases := 80
  else
    set lng_Pct_Small_Bases := 100
  endif

  // Cue Cappa Weapon Platform size distribution
  if Is_Vehicle_Size_Available("Large Weapon Platform") then
    set lng_Pct_Small_WPs := 50
    set lng_Pct_Large_WPs := 50
  else
    set lng_Pct_Small_WPs := 100
  endif

  // Cue Cappa vehicle amount modifiers
  // Empire size
  set empire_mod := Sys_Divide_Long(lng_AI_Empire_Num_Facilities, 1500)

  // Diplomacy
  if (bool_Race_Is_Not_Alone) then
    set explore_mod := explore_mod - 6
    set scout_mod := scout_mod + 6
    set patrol_mod := patrol_mod + 4
  else
    set explore_mod := explore_mod + 18
  endif

  if (lng_AI_Num_Of_Enemies > 0) then
    set patrol_mod := patrol_mod + 8
    set mine_mod := mine_mod + 1000
  endif

  // Combat performance
  if (bool_Race_Losing_Colonies_In_Combat) then
    set wp_mod := wp_mod + 100
    set sat_mod := sat_mod + 100
    set base_mod := base_mod + 4
  endif

  if (bool_Race_Ground_Combat_Poor) then
    set troop_mod := troop_mod + 1000
  endif

  // Technology
  if Is_Vehicle_Size_Available("Baseship") then
    set baseship_mod := baseship_mod + 8
  endif

  // Enemy designs
  if (bool_Enemy_Uses_Seeker_Weapons) then
    set attack_mod := attack_mod - 6
    set defense_mod := defense_mod + 8
    set pd_mod := pd_mod + 4
  endif

  if (bool_Enemy_Ships_Are_Much_Faster) then
    set bool_Race_Uses_Remote_Fighters := TRUE
    set fighter_mod := fighter_mod + 400
    set drone_mod := drone_mod + 100
    set carrier_mod := carrier_mod + 4
  endif

  // Resource availability
  if (bool_Race_Minerals_Prod_Low) or (bool_Race_Maintenance_High) then
    set minerals_mod := minerals_mod + 8
  endif
  if (bool_Race_Organics_Prod_Low) or (bool_Race_Maintenance_High) then
    set organics_mod := organics_mod + 2
  endif
  if (bool_Race_Radioactives_Prod_Low) or (bool_Race_Maintenance_High) then
    set radioactives_mod := radioactives_mod + 3
  endif

  // Cue Cappa Empire strategy
  if (bool_AI_Strategy_Peaceful) then
    // No changes
  endif

  if (bool_AI_Strategy_Defend) then
    set attack_mod := attack_mod - 24
    set defense_mod := defense_mod + 12
    set pd_mod := pd_mod + 4
    set wp_mod := wp_mod + 60
    set sat_mod := sat_mod + 120
    set mine_mod := mine_mod + 2000
    set base_mod := base_mod + 4
  endif

  if (bool_AI_Strategy_Buildup) then
    set attack_mod := attack_mod + 24
    set defense_mod := defense_mod - 12
    set pd_mod := pd_mod + 4
  endif

  if (bool_AI_Strategy_Attack) then
    set attack_mod := attack_mod + 20
    set seeker_mod := seeker_mod + 20
    set pd_mod := pd_mod + 5
    set fighter_mod := fighter_mod + 500
  endif

  if (bool_AI_Strategy_Last_Stand) or (bool_AI_Strategy_Flame_Out) then
    set attack_mod := attack_mod - 32
    set defense_mod := defense_mod - 36
    set explore_mod := -12
    set empire_mod := -4
    set wp_mod := wp_mod + 120
    set sat_mod := sat_mod + 240
    set mine_mod := mine_mod + 4000
  endif

  // Design strategy
  if (bool_AI_Design_Preference_Seeker) then
    set attack_mod := attack_mod - 32
    set seeker_mod := seeker_mod + 32
  endif

  // Cue Cappa wanted vehicles per 1000 facilities
  // Ships
  set lng_Num_Attack_Ships             := 64 + attack_mod + Sys_Divide_Long(size_mod, 2)
  set lng_Num_Defense_Ships            := 72 + defense_mod + Sys_Divide_Long(size_mod, 2)
  set lng_Num_Seeker_Ships             := 0 + seeker_mod
  set lng_Num_PD_Ships                 := 16 + pd_mod
  set lng_Num_Explorer_Ships           := 12 + explore_mod
  set lng_Num_Scout_Ships              := 0 + scout_mod
  set lng_Num_Patrol_Ships             := 4 + patrol_mod
  set lng_Num_Boarding_Ships           := 0
  set lng_Num_Bombardment_Ships        := 0
  set lng_Num_Kamikaze_Ships           := 0
  set lng_Num_Carriers                 := 0 + carrier_mod
  set lng_Num_Drone_Carriers           := 0 + Sys_Divide_Long(drone_mod, 100)
  set lng_Num_Base_Ships               := 0 + baseship_mod
  set lng_Num_Space_Yard_Ships         := 4 - empire_mod
  set lng_Num_Repair_Ships             := 6 - empire_mod
  set lng_Num_Supply_Transports        := 6 - empire_mod
  set lng_Num_Troop_Transports         := 6 - empire_mod
  set lng_Num_Cargo_Transports         := 6 - empire_mod
  set lng_Num_Pop_Transports           := 4 - empire_mod
  set lng_Num_Plague_Ships             := 0
  set lng_Num_Sat_Layers               := 0 - empire_mod
  set lng_Num_Mine_Layers              := 6 - empire_mod
  set lng_Num_Mine_Sweepers            := 12
  set lng_Num_Mining_Ships             := 12 + minerals_mod
  set lng_Num_Farming_Ships            := 4 + organics_mod
  set lng_Num_Refining_Ships           := 4 + radioactives_mod

  // Bases
  set lng_Num_Base_Space_Yards         := 8 - empire_mod
  set lng_Num_Defense_Bases            := 16 + base_mod

  // Troops
  If Is_Vehicle_Size_Available("Large Troop") then
    set lng_Num_Troops                 := 600 + Sys_Divide_Long(troop_mod, 2)
    set lng_Num_Light_Troops           := 1800 + Sys_Divide_Long(troop_mod, 2)
    set lng_Num_Heavy_Troops           := 200
  else
    If Is_Vehicle_Size_Available("Medium Troop") then
      set lng_Num_Troops               := 800 + Sys_Divide_Long(troop_mod, 2)
      set lng_Num_Light_Troops         := 1600 + Sys_Divide_Long(troop_mod, 2)
    else
      set lng_Num_Troops               := 2000 + troop_mod
    endif
  endif

  // Fighters
  set lng_Num_Fighters                 := 1200 + Sys_Divide_Long(fighter_mod, 2)
  set lng_Num_Fighter_Bombers          := 400 + Sys_Divide_Long(fighter_mod, 2)
  set lng_Num_Kamikaze_Fighters        := 0

  // Weapon Platforms
  set lng_Num_Weapon_Platforms         := 360 + wp_mod
  set lng_Num_Seeker_WPs               := 0

  // Satellites
  set lng_Num_Satellites               := 240 + sat_mod
  set lng_Num_PD_Sats                  := 40 + Sys_Multiply_Long(pd_mod, 5)
  set lng_Num_Seeker_Sats              := 0
  set lng_Num_Recon_Sats               := 20
  set lng_Num_Repair_Sats              := 20

  // Mines
  set lng_Num_Mines                    := 4000 + mine_mod

  // Drones
  set lng_Num_Atk_Drones               := 40 + Sys_Divide_Long(drone_mod, 2)
  set lng_Num_Def_Drones               := 120 + Sys_Divide_Long(drone_mod, 2)
  set lng_Num_Seeker_Drones            := 0
  set lng_Num_Kamikaze_Drones          := 0
  set lng_Num_Bombardment_Drones       := 0
  set lng_Num_Repair_Drones            := 0

  return TRUE
end

//------------------------------------------------------------------------
// Set_Race_Research_Spending
//------------------------------------------------------------------------
function Set_Race_Research_Spending returns boolean
vars
  research_pts:              long
  research_mod:              long
begin

  // Get our current research points
  set research_pts := Sys_Get_Empire_Current_Points(sys_long_Player_ID, POINT_TYPE_RESEARCH)

  // Set our base research and intel point percentages (Should add to 100)
  set lng_Pct_Pts_Research := 80
  set lng_Pct_Pts_Intel := 20

  // Set research modifier
  set research_mod := Sys_Min_Long(Sys_Divide_Long(research_pts, 10000), 15)

  // Cue Cappa research spending groups
  call lst_Research_Spending_Group_Name.add("Cultural Advancement")
  call lst_Research_Spending_Group_Name.add("Theoretical Science")
  call lst_Research_Spending_Group_Name.add("Applied Science")
  call lst_Research_Spending_Group_Name.add("Weapon Technology")

  // Cue Cappa research group spending
  case Sys_Get_AI_State(sys_long_Player_ID)
    AI_STATE_EXPLORE_AND_EXPAND:
      call lst_Research_Spending_For_Group.add(1)
      call lst_Research_Spending_For_Group.add(40 + research_mod)
      call lst_Research_Spending_For_Group.add(39)
      call lst_Research_Spending_For_Group.add(20 - research_mod)
    AI_STATE_INFRASTRUCTURE:
      call lst_Research_Spending_For_Group.add(5)
      call lst_Research_Spending_For_Group.add(25 - research_mod)
      call lst_Research_Spending_For_Group.add(45 + (research_mod * 2))
      call lst_Research_Spending_For_Group.add(25 - research_mod)
    AI_STATE_ATTACK:
      call lst_Research_Spending_For_Group.add(1)
      call lst_Research_Spending_For_Group.add(19 - research_mod)
      call lst_Research_Spending_For_Group.add(45 + (research_mod * 2))
      call lst_Research_Spending_For_Group.add(35 - research_mod)
    AI_STATE_DEFEND:
      call lst_Research_Spending_For_Group.add(1)
      call lst_Research_Spending_For_Group.add(19 - research_mod)
      call lst_Research_Spending_For_Group.add(50 + (research_mod * 2))
      call lst_Research_Spending_For_Group.add(30 - research_mod)
    AI_STATE_NOT_CONNECTED:
      if Is_Tech_Area_Visible("Stellar Manipulation") then
        call lst_Research_Spending_For_Group.add(1)
        call lst_Research_Spending_For_Group.add(10)
        call lst_Research_Spending_For_Group.add(80)
        call lst_Research_Spending_For_Group.add(9)
      else
        call lst_Research_Spending_For_Group.add(1)
        call lst_Research_Spending_For_Group.add(70)
        call lst_Research_Spending_For_Group.add(20)
        call lst_Research_Spending_For_Group.add(9)
      endif
  endcase

  // Set research priority level based on number of wars we are in
  set lng_Research_Priority_Level := RESEARCH_PRIORITY_LOW

  if (lng_AI_Num_Of_Wars = 2) then
    set lng_Research_Priority_Level := RESEARCH_PRIORITY_MEDIUM
  endif
  if (lng_AI_Num_Of_Wars = 3) then
    set lng_Research_Priority_Level := RESEARCH_PRIORITY_HIGH
  endif
  if (lng_AI_Num_Of_Wars >= 4) then
    set lng_Research_Priority_Level := RESEARCH_PRIORITY_CRITICAL
  endif

  return TRUE
end

//------------------------------------------------------------------------
// Set_Race_Research_Areas
//------------------------------------------------------------------------
function Set_Race_Research_Areas returns boolean
begin

  // Cue Cappa weapons to research
  if Is_Tech_Area_Visible("Weapon Mounts") then
    call Add_Tech_Area_To_Research_List("Weapon Mounts", 1, Is_Tech_Area_Available("Small Ship Construction", 6))
  endif

  if Is_Tech_Area_Visible("Psychic Weapons") then
    // Psychic weapons
    call Add_Tech_Area_To_Research_List("Psychic Weapons", 15, TRUE)
  endif

  if Is_Tech_Area_Visible("Energy Stream Weapons") then
    // Anti-Proton Beam
    call Add_Tech_Area_To_Research_List("Energy Stream Weapons", 11, TRUE)
  else
    // X-Ray Laser
    call Add_Tech_Area_To_Research_List("Focused-Energy Weapons", 11, TRUE)
  endif

  if Is_Tech_Area_Visible("Torpedo Weapons") then
    // Anti-Matter Torpedo, Quantum Torpedo
    call Add_Tech_Area_To_Research_List("Torpedo Weapons", 16, TRUE)
  else
    if Is_Tech_Area_Visible("Plasma Missile Weapons") then
      // Plasma Missile
      call Add_Tech_Area_To_Research_List("Plasma Missile Weapons", 11, TRUE)
    else
      // Capital Ship Missile
      call Add_Tech_Area_To_Research_List("Missile Weapons", 11, TRUE)
    endif
  endif

  if Is_Tech_Area_Visible("Shield Implosion") then
    // Shield Imploder (Ruins)
    call Add_Tech_Area_To_Research_List("Shield Implosion", 3, TRUE)
  endif

  return TRUE
end

//------------------------------------------------------------------------
// Set_Race_Weapon_Choices
//------------------------------------------------------------------------
function Set_Race_Weapon_Choices returns boolean
params
  vehicle_type:              string
  vehicle_tonnage:           long
  design_type:               string
begin

  // Clear previous lists
  call lst_Primary_Weapon_Name.clear()
  call lst_Secondary_Weapon_Name.clear()
  call lst_Heavy_Weapon_Name.clear()
  call lst_Special_Weapon_Name.clear()
  call lst_Bombardment_Weapon_Name.clear()
  call lst_Primary_PD_Weapon_Name.clear()
  call lst_Secondary_PD_Weapon_Name.clear()
  call lst_Special_PD_Weapon_Name.clear()
  call lst_Primary_Armor_Name.clear()
  call lst_Secondary_Armor_Name.clear()

  // Cue Cappa Ship weapon choices
  // Ship (Attack) = Primary + Heavy (>=400kT) + Special (>=750kT)
  // Ship (Defense) = Secondary + Heavy (>=400kT) + Special (>=750kT)
  // Ship (Seeker) = Primary (>=450kT) + Heavy
  if (vehicle_type = "Ship") then
    // Primary
    call Add_Weapon_To_List("Anti-Proton Beam", "Primary", TRUE)
    call Add_Weapon_To_List("Telekinetic Projector", "Primary", TRUE)
    call Add_Weapon_To_List("X-Ray Laser", "Primary", TRUE)
    // Secondary
    call Add_Weapon_To_List("Shield Imploder", "Secondary", bool_Enemy_Uses_Mostly_Shields and vehicle_tonnage < 450)
    call Add_Weapon_To_List("Telekinetic Projector", "Secondary", TRUE)
    call Add_Weapon_To_List("X-Ray Laser", "Secondary", TRUE)
    // Heavy
    call Add_Weapon_To_List("Mental Singularity Generator", "Heavy", bool_AI_Design_Preference_Direct_Fire)
    call Add_Weapon_To_List("Quantum Torpedo", "Heavy", bool_Enemy_Ships_Are_Faster or bool_AI_Design_Preference_Seeker)
    call Add_Weapon_To_List("Anti-Matter Torpedo", "Heavy", bool_Enemy_Ships_Are_Faster or bool_AI_Design_Preference_Seeker)
    call Add_Weapon_To_List("Plasma Missile", "Heavy", bool_Enemy_Ships_Are_Faster or bool_AI_Design_Preference_Seeker)
    call Add_Weapon_To_List("Capital Ship Missile", "Heavy", TRUE)
    // Special
    call Add_Weapon_To_List("Allegiance Subverter", "Special", TRUE)
    call Add_Weapon_To_List("Shield Imploder", "Special", bool_Enemy_Uses_Mostly_Shields)
    call Add_Weapon_To_List("Telekinetic Projector", "Special", TRUE)
    // Bombardment
    call Add_Weapon_To_List("Smart Bomb (Cargo)", "Bombardment", TRUE)
    call Add_Weapon_To_List("Plasma Missile", "Bombardment", TRUE)
    call Add_Weapon_To_List("Capital Ship Missile", "Bombardment", TRUE)
  endif

  // Cue Cappa Base weapon choices
  // Primary + Secondary (Max 2-4) + Heavy + Special (Max 1-2)
  if (vehicle_type = "Base") then
    // Primary
    call Add_Weapon_To_List("Anti-Proton Beam", "Primary", TRUE)
    call Add_Weapon_To_List("X-Ray Laser", "Primary", TRUE)
    // Secondary
    call Add_Weapon_To_List("Telekinetic Projector", "Secondary", TRUE)
    call Add_Weapon_To_List("X-Ray Laser", "Secondary", TRUE)
    // Heavy
    call Add_Weapon_To_List("Mental Singularity Generator", "Heavy", bool_AI_Design_Preference_Direct_Fire)
    call Add_Weapon_To_List("Quantum Torpedo", "Heavy", bool_Enemy_Ships_Are_Faster or bool_AI_Design_Preference_Seeker)
    call Add_Weapon_To_List("Anti-Matter Torpedo", "Heavy", bool_Enemy_Ships_Are_Faster or bool_AI_Design_Preference_Seeker)
    call Add_Weapon_To_List("Plasma Missile", "Heavy", bool_Enemy_Ships_Are_Faster or bool_AI_Design_Preference_Seeker)
    call Add_Weapon_To_List("Telekinetic Projector", "Heavy", TRUE)
    call Add_Weapon_To_List("Capital Ship Missile", "Heavy", TRUE)
    // Special
    call Add_Weapon_To_List("Shield Imploder", "Special", bool_Enemy_Uses_Mostly_Shields)
    call Add_Weapon_To_List("Mental Flailer", "Special", TRUE)
    call Add_Weapon_To_List("Telekinetic Projector", "Special", TRUE)
  endif

  // Cue Cappa Troop weapon choices
  // Troop (Light) = Primary
  // Troop = Primary + Secondary (>=18kT)
  // Troop (Heavy) = Heavy
  if (vehicle_type = "Troop") then
    // Primary
    call Add_Weapon_To_List("Small Anti-Proton Beam", "Primary", TRUE)
    call Add_Weapon_To_List("Ground Cannon", "Primary", TRUE)
    // Secondary
    call Add_Weapon_To_List("Small Telekinetic Projector", "Secondary", TRUE)
    call Add_Weapon_To_List("Small Depleted Uranium Cannon", "Secondary", TRUE)
    // Heavy
    call Add_Weapon_To_List("Rocket Pods", "Heavy", TRUE)
    call Add_Weapon_To_List("Small Telekinetic Projector", "Heavy", TRUE)
  endif

  // Cue Cappa Fighter weapon choices
  // Fighter = Primary + Secondary (>=20kT)
  // Fighter (Bomber) = Heavy
  if (vehicle_type = "Fighter") then
    // Primary
    call Add_Weapon_To_List("Small Anti-Proton Beam", "Primary", TRUE)
    call Add_Weapon_To_List("Small X-Ray Laser", "Primary", TRUE)
    // Secondary
    call Add_Weapon_To_List("Small Telekinetic Projector", "Secondary", TRUE)
    call Add_Weapon_To_List("Small X-Ray Laser", "Secondary", TRUE)
    // Heavy
    call Add_Weapon_To_List("Small Quantum Torpedo", "Heavy", TRUE)
    call Add_Weapon_To_List("Small Anti-Matter Torpedo", "Heavy", TRUE)
    call Add_Weapon_To_List("Small Plasma Missile", "Heavy", TRUE)
    call Add_Weapon_To_List("Small Nuclear Missile", "Heavy", TRUE)
  endif

  // Cue Cappa Satellite weapon choices
  // Satellite = Primary + Secondary (>=100kT)
  // Satellite (Seeker) = Heavy
  if (vehicle_type = "Satellite") then
    // Primary
    call Add_Weapon_To_List("Anti-Proton Beam", "Primary", TRUE)
    call Add_Weapon_To_List("X-Ray Laser", "Primary", TRUE)
    // Secondary
    call Add_Weapon_To_List("Telekinetic Projector", "Secondary", TRUE)
    call Add_Weapon_To_List("X-Ray Laser", "Secondary", TRUE)
    // Heavy
    call Add_Weapon_To_List("Quantum Torpedo", "Heavy", bool_Enemy_Ships_Are_Faster or bool_AI_Design_Preference_Seeker)
    call Add_Weapon_To_List("Anti-Matter Torpedo", "Heavy", bool_Enemy_Ships_Are_Faster or bool_AI_Design_Preference_Seeker)
    call Add_Weapon_To_List("Plasma Missile", "Heavy", bool_Enemy_Ships_Are_Faster or bool_AI_Design_Preference_Seeker)
    call Add_Weapon_To_List("Capital Ship Missile", "Heavy", TRUE)
  endif

  // Cue Cappa Weapon Platform weapon choices
  // Weapon Platform = Primary + Secondary (Max 1-3) + Heavy + Special (Max 1-3)
  // Weapon Platform (Seeker) = Heavy
  if (vehicle_type = "Weapon Platform") then
    // Primary
    call Add_Weapon_To_List("Anti-Proton Beam", "Primary", TRUE)
    call Add_Weapon_To_List("X-Ray Laser", "Primary", TRUE)
    // Secondary
    call Add_Weapon_To_List("Telekinetic Projector", "Secondary", TRUE)
    call Add_Weapon_To_List("X-Ray Laser", "Secondary", TRUE)
    // Heavy
    call Add_Weapon_To_List("Mental Singularity Generator", "Heavy", bool_AI_Design_Preference_Direct_Fire)
    call Add_Weapon_To_List("Quantum Torpedo", "Heavy", bool_Enemy_Ships_Are_Faster or bool_AI_Design_Preference_Seeker)
    call Add_Weapon_To_List("Anti-Matter Torpedo", "Heavy", bool_Enemy_Ships_Are_Faster or bool_AI_Design_Preference_Seeker)
    call Add_Weapon_To_List("Plasma Missile", "Heavy", bool_Enemy_Ships_Are_Faster or bool_AI_Design_Preference_Seeker)
    call Add_Weapon_To_List("Telekinetic Projector", "Heavy", TRUE)
    call Add_Weapon_To_List("Capital Ship Missile", "Heavy", TRUE)
    // Special
    call Add_Weapon_To_List("Shield Imploder", "Special", bool_Enemy_Uses_Mostly_Shields)
    call Add_Weapon_To_List("Mental Flailer", "Special", TRUE)
    call Add_Weapon_To_List("Telekinetic Projector", "Special", TRUE)
  endif

  // Cue Cappa Drone weapon choices
  // Drone (Attack) = Primary
  // Drone (Defense) = Secondary + Heavy
  // Drone (Bombardment) = Bombardment
  if (vehicle_type = "Drone") then
    // Primary
    call Add_Weapon_To_List("Anti-Proton Beam", "Primary", TRUE)
    call Add_Weapon_To_List("X-Ray Laser", "Primary", TRUE)
    // Secondary
    call Add_Weapon_To_List("Shield Imploder", "Secondary", bool_Enemy_Uses_Mostly_Shields)
    call Add_Weapon_To_List("Anti-Proton Beam", "Secondary", TRUE)
    call Add_Weapon_To_List("X-Ray Laser", "Secondary", TRUE)
    // Heavy
    call Add_Weapon_To_List("Quantum Torpedo", "Heavy", bool_Enemy_Ships_Are_Faster or bool_AI_Design_Preference_Seeker)
    call Add_Weapon_To_List("Anti-Matter Torpedo", "Heavy", bool_Enemy_Ships_Are_Faster or bool_AI_Design_Preference_Seeker)
    call Add_Weapon_To_List("Plasma Missile", "Heavy", bool_Enemy_Ships_Are_Faster or bool_AI_Design_Preference_Seeker)
    call Add_Weapon_To_List("Capital Ship Missile", "Heavy", TRUE)
    // Bombardment
    call Add_Weapon_To_List("Smart Bomb (Cargo)", "Bombardment", TRUE)
    call Add_Weapon_To_List("Plasma Missile", "Bombardment", TRUE)
    call Add_Weapon_To_List("Capital Ship Missile", "Bombardment", TRUE)
  endif

  // Cue Cappa Point-Defense Choices
  // Primary Point-Defense Weapon
  call Add_Weapon_To_List("Point-Defense Beam", "Primary PD", TRUE)
  call Add_Weapon_To_List("Point-Defense Cannons", "Primary PD", TRUE)
  // Secondary Point-Defense Weapon
  call Add_Weapon_To_List("Point-Defense Cannons", "Secondary PD", TRUE)
  call Add_Weapon_To_List("Point-Defense Blaster", "Secondary PD", vehicle_tonnage < 450)
  // Special Point-Defense Weapon
  call Add_Weapon_To_List("Bomblet Missile", "Special PD", bool_Enemy_Uses_Long_Range_Seeker_Weapons)
  call Add_Weapon_To_List("Anti-Fighter Rocket", "Special PD", TRUE)
  call Add_Weapon_To_List("Point-Defense Cannons", "Special PD", TRUE)

  // Cue Cappa Armor choices
  if (vehicle_type = "Troop") or (vehicle_type = "Fighter") then
    call lst_Primary_Armor_Name.add("Small Armor")
    call lst_Secondary_Armor_Name.add("Small Emissive Armor")
  else
    call lst_Primary_Armor_Name.add("Heavy Armor")
    call lst_Secondary_Armor_Name.add("Emissive Armor")
  endif

  return TRUE
end

//------------------------------------------------------------------------
// Set_Race_Overall_Spending_Percentages
//------------------------------------------------------------------------
function Set_Race_Overall_Spending_Percentages returns boolean
vars
  ai_state:                  long
begin
  set ai_state := Sys_Get_AI_State(sys_long_Player_ID)

  // Set our construction focus
  case ai_state
    AI_STATE_EXPLORE_AND_EXPAND:
      set lng_Vehicle_Construction_Priority_Level := VEHICLE_PRIORITY_MEDIUM
    AI_STATE_INFRASTRUCTURE:
      set lng_Vehicle_Construction_Priority_Level := VEHICLE_PRIORITY_MEDIUM
    AI_STATE_ATTACK:
      set lng_Vehicle_Construction_Priority_Level := VEHICLE_PRIORITY_HIGH
    AI_STATE_DEFEND:
      set lng_Vehicle_Construction_Priority_Level := VEHICLE_PRIORITY_MEDIUM
    AI_STATE_NOT_CONNECTED:
      set lng_Vehicle_Construction_Priority_Level := VEHICLE_PRIORITY_LOW
  endcase

  if (bool_Race_Maintenance_High) or (bool_Race_Minerals_Low) or (bool_Race_Organics_Low) or (bool_Race_Radioactives_Low) then
    set lng_Vehicle_Construction_Priority_Level := VEHICLE_PRIORITY_LOW
  endif

  return TRUE
end

//------------------------------------------------------------------------
// Set_Race_Strategy_Preferences
//------------------------------------------------------------------------
function Set_Race_Strategy_Preferences returns boolean
vars
begin

  // Cue Cappa ship strategies
  set lng_Atk_Ship_Atk_Strat := Sys_Get_Strategy_With_Name(sys_long_Player_ID, "Short Range")
  set lng_Atk_Ship_Def_Strat := Sys_Get_Strategy_With_Name(sys_long_Player_ID, "Short Range")
  set lng_Def_Ship_Atk_Strat := Sys_Get_Strategy_With_Name(sys_long_Player_ID, "Optimal Range")
  set lng_Def_Ship_Def_Strat := Sys_Get_Strategy_With_Name(sys_long_Player_ID, "Optimal Range")
  set lng_Skr_Ship_Atk_Strat := Sys_Get_Strategy_With_Name(sys_long_Player_ID, "Maximum Range")
  set lng_Skr_Ship_Def_Strat := Sys_Get_Strategy_With_Name(sys_long_Player_ID, "Maximum Range")

  // Cue Cappa fleet formations
  // Mostly direct fire ships
  if (lng_AI_Empire_Design_Strategy = AI_DESIGN_STRATEGY_DIRECTFIRE or lng_AI_Empire_Design_Strategy = AI_DESIGN_STRATEGY_DIRECTFIRE_SMALL) then
    set lng_TF_Fill_Strategy := AI_TASK_FORCE_FILL_SEQUENTIAL
    set lng_Atk_Fleet_Atk_Form := Sys_Get_Fleet_Formation_With_Name("Trident (S)")
    set lng_Atk_Fleet_Def_Form := Sys_Get_Fleet_Formation_With_Name("Trident (S)")
    set lng_Def_Fleet_Atk_Form := Sys_Get_Fleet_Formation_With_Name("Trident (S)")
    set lng_Def_Fleet_Def_Form := Sys_Get_Fleet_Formation_With_Name("Trident (S)")
  else
    // Mix of direct fire and seeker ships
    if (lng_AI_Empire_Design_Strategy = AI_DESIGN_STRATEGY_MIXED or lng_AI_Empire_Design_Strategy = AI_DESIGN_STRATEGY_MIXED_SMALL) then
      set lng_TF_Fill_Strategy := AI_TASK_FORCE_FILL_SPREAD_TWO
      set lng_Atk_Fleet_Atk_Form := Sys_Get_Fleet_Formation_With_Name("X (S)")
      set lng_Atk_Fleet_Def_Form := Sys_Get_Fleet_Formation_With_Name("X (S)")
      set lng_Def_Fleet_Atk_Form := Sys_Get_Fleet_Formation_With_Name("X (S)")
      set lng_Def_Fleet_Def_Form := Sys_Get_Fleet_Formation_With_Name("X (S)")
    else
      // Mostly seeker ships
      set lng_TF_Fill_Strategy := AI_TASK_FORCE_FILL_SEQUENTIAL
      set lng_Atk_Fleet_Atk_Form := Sys_Get_Fleet_Formation_With_Name("Wall (S)")
      set lng_Atk_Fleet_Def_Form := Sys_Get_Fleet_Formation_With_Name("Wall (S)")
      set lng_Def_Fleet_Atk_Form := Sys_Get_Fleet_Formation_With_Name("Wall (S)")
      set lng_Def_Fleet_Def_Form := Sys_Get_Fleet_Formation_With_Name("Wall (S)")
    endif
  endif

  // Cue Cappa task force formations
  set lng_TF_Atk_Ship_Atk_Form := Sys_Get_Task_Force_Formation_With_Name("Pincer (S)")
  set lng_TF_Atk_Ship_Def_Form := Sys_Get_Task_Force_Formation_With_Name("Flying V (S)")
  set lng_TF_Def_Ship_Atk_Form := Sys_Get_Task_Force_Formation_With_Name("Pincer (S)")
  set lng_TF_Def_Ship_Def_Form := Sys_Get_Task_Force_Formation_With_Name("Flying V (S)")
  set lng_TF_Skr_Ship_Atk_Form := Sys_Get_Task_Force_Formation_With_Name("Wall (S)")
  set lng_TF_Skr_Ship_Def_Form := Sys_Get_Task_Force_Formation_With_Name("Wall (S)")

  return TRUE
end

//------------------------------------------------------------------------
// Set_Race_Political_Settings
//------------------------------------------------------------------------
function Set_Race_Political_Settings returns boolean
begin

  // Cue Cappa speech file
  set str_Politics_Speech_Datafile_Filename                          := "CueCappa_AI_Speech.txt"

 // Cue Cappa diplomacy values
  set lng_Political_Message_Score_Percent_For_Demanding_Tone         := 80
  set lng_Political_Message_Score_Percent_For_Pleading_Tone          := 125
  set lng_Politics_Base_Anger_Level                                  := 50
  set lng_Politics_Min_Anger_Allowed                                 := 10
  set lng_Politics_Anger_Reduction_For_Wars                          := 8
  set lng_Politics_Anger_Reduction_For_Similarity                    := 5
  set lng_Politics_Max_Anger_To_Propose_Treaty                       := 60
  set lng_Politics_Max_Anger_To_Accept_Treaty                        := 70
  set lng_Politics_Max_Anger_To_Counter_Treaty                       := 70
  set lng_Politics_Max_Anger_To_Accept_Gift                          := 100
  set lng_Politics_Max_Anger_To_Trade                                := 80
  set lng_Politics_Min_Anger_To_Declare_War                          := 90
  set lng_Politics_Min_Time_To_Declare_War                           := 15
  set lng_Politics_Min_Anger_To_Break_Treaty                         := 70
  set lng_Politics_Min_Time_To_Break_Treaty                          := 15
  set lng_Politics_Trade_Value_Percent_For_Enemy                     := 120
  set lng_Politics_Trade_Value_Percent_For_Friend                    := 110
  set lng_Politics_Min_Fear_To_Make_Peace                            := 15
  set lng_Politics_Min_Fear_To_Surrender                             := 50
  set lng_Politics_Min_Fear_To_Give_Enemy_Gift                       := 15
  set lng_Politics_Min_Fear_To_Give_Friend_Gift                      := 5
  set lng_Politics_Min_Fear_To_Accept_Enemy_Demand                   := 20
  set lng_Politics_Min_Fear_To_Accept_Friend_Demand                  := 15
  set lng_Politics_Max_Concurrent_Requests_To_Honor_From_One_Player  := 2
  set lng_Politics_Max_Time_To_Honor_A_Request                       := 5
  set lng_Politics_Percent_Chance_To_Propose_Treaty                  := 25
  set lng_Politics_Percent_Chance_To_Change_Treaty                   := 5

  set lng_Politics_Friendship_Pts_Ok_Friend                          := 5
  set lng_Politics_Friendship_Pts_Good_Friend                        := 8

  // Cue Cappa alliance diplomacy values
  set lng_Politics_Max_Anger_To_Propose_Alliance                     := 40
  set lng_Politics_Max_Anger_To_Accept_Alliance                      := 50
  set lng_Politics_Max_Anger_To_Counter_Alliance                     := 50
  set lng_Politics_Alliance_Max_Anger_To_Add_Member                  := 50
  set lng_Politics_Alliance_Min_Anger_To_Remove_Member               := 70
  set lng_Politics_Alliance_Max_Anger_To_Accept_Rule_Change          := 50
  set lng_Politics_Alliance_Max_Anger_To_Accept_Send_Message         := 70
  set lng_Politics_Alliance_Max_Anger_To_Accept_Reply_Message        := 70

  // Cue Cappa anger amounts for political status
  set lng_Politics_Max_Friendship_Pts_For_Anger                      := 8
  set lng_Politics_Anger_Amount_For_Known_Status_Time                := 1
  set lng_Politics_Anger_Amount_For_Treaty_Status_Time               := -3
  set lng_Politics_Anger_Amount_For_War_Status_Time                  := 4
  set lng_Politics_Anger_Amount_Friend_Of_Friend                     := -3
  set lng_Politics_Anger_Amount_Friend_Of_Enemy                      := 2
  set lng_Politics_Anger_Amount_Enemy_Of_Enemy                       := -3
  set lng_Politics_Anger_Amount_Enemy_Of_Friend                      := 2
  set lng_Politics_Min_Anger_For_Political_Status                    := -20
  set lng_Politics_Max_Anger_For_Political_Status                    := 20
  set lng_Politics_Min_Anger_For_Political_Status_With_Others        := -10
  set lng_Politics_Max_Anger_For_Political_Status_With_Others        := 10
  set lng_Politics_Min_Anger_Flux                                    := -2
  set lng_Politics_Max_Anger_Flux                                    := 2

  set lng_Politics_Anger_Reduction_For_Wars                          := -15
  set lng_Politics_Anger_Reduction_For_Similarity                    := -5
  set lng_Politics_Anger_Increase_For_Dissimilarity                  := 5
  set lng_Politics_Anger_Increase_For_Mega_Evil                      := 20
  set lng_Politics_Anger_Reduction_For_Mega_Evil                     := -15
  set lng_Politics_Anger_Reduction_For_AI_Team                       := -15
  set lng_Politics_Anger_Reduction_For_Common_Enemy                  := -10
  set lng_Politics_Anger_Increase_For_Friendly_Galaxy                := 10

  // Cue Cappa anger amounts for events
  // Combat
  set lng_AI_Anger_Amount_Space_Combat_Won                           := 2
  set lng_AI_Anger_Amount_Space_Combat_Lost                          := 4
  set lng_AI_Anger_Amount_Space_Combat_Stalemate                     := 3
  set lng_AI_Anger_Amount_Ground_Combat_Won                          := 3
  set lng_AI_Anger_Amount_Ground_Combat_Lost                         := 5
  set lng_AI_Anger_Amount_Ground_Combat_Stalemate                    := 4
  set lng_AI_Anger_Amount_Mine_Explosion                             := 2

  // Treaty benefits
  set lng_AI_Anger_Amount_Treaty_Designs_Received                    := -2
  set lng_AI_Anger_Amount_Treaty_Maps_Received                       := -2
  set lng_AI_Anger_Amount_Treaty_Tech_Provided                       := -3
  set lng_AI_Anger_Amount_Treaty_Comm_Channels_Provided              := -2
  set lng_AI_Anger_Amount_Treaty_Espionage_Info_Provided             := -2
  set lng_AI_Anger_Amount_Treaty_Combat_Info_Provided                := -2

  // Intel events
  set lng_AI_Anger_Amount_Espionage                                  := 2
  set lng_AI_Anger_Amount_Sabotage                                   := 3
  set lng_AI_Anger_Amount_Planet_Cargo_Bomb                          := 5
  set lng_AI_Anger_Amount_Planet_Conditions_Change                   := 3
  set lng_AI_Anger_Amount_Planet_Plagued                             := 10
  set lng_AI_Anger_Amount_Planet_Population_Change                   := 5
  set lng_AI_Anger_Amount_Planet_Anger_Change                        := 3
  set lng_AI_Anger_Amount_Planet_Riot                                := 5
  set lng_AI_Anger_Amount_Planet_Rebel                               := 10
  set lng_AI_Anger_Amount_Planet_Value_Change                        := 5
  set lng_AI_Anger_Amount_Points_Change                              := 5
  set lng_AI_Anger_Amount_Ship_Damaged                               := 3
  set lng_AI_Anger_Amount_Ship_Cargo_Bomb                            := 3
  set lng_AI_Anger_Amount_Ship_Lost_Supply                           := 3
  set lng_AI_Anger_Amount_Ship_Lost_Movement                         := 3
  set lng_AI_Anger_Amount_Ship_Lost_Experience                       := 3
  set lng_AI_Anger_Amount_Ship_Orders_Changed                        := 3
  set lng_AI_Anger_Amount_Ship_Rebel                                 := 5

  // Stellar Manipualtion
  set lng_AI_Anger_Amount_Planet_Destroyed                           := 3
  set lng_AI_Anger_Amount_Star_Destroyed                             := 5
  set lng_AI_Anger_Amount_Blackhole_Created                          := 5
  set lng_AI_Anger_Amount_Nebulae_Created                            := 5
  set lng_AI_Anger_Amount_WP_Closed                                  := 3
  set lng_AI_Anger_Amount_WP_Opened                                  := 0

  // Cue Cappa Anger Amounts for Log Messages
  set lng_AI_Anger_Amount_Msg_General                                := -2
  set lng_AI_Anger_Amount_Msg_Reply                                  := -2
  set lng_AI_Anger_Amount_Msg_Declare_War                            := 20
  set lng_AI_Anger_Amount_Msg_Grant_Independence                     := 5
  set lng_AI_Anger_Amount_Msg_Propose_Treaty                         := -5
  set lng_AI_Anger_Amount_Msg_Accept_Treaty                          := -10
  set lng_AI_Anger_Amount_Msg_Accept_Treaty_Changes                  := -5
  set lng_AI_Anger_Amount_Msg_Refuse_Treaty                          := 5
  set lng_AI_Anger_Amount_Msg_Refuse_Treaty_Changes                  := 2
  set lng_AI_Anger_Amount_Msg_Counter_Treaty                         := -2
  set lng_AI_Anger_Amount_Msg_Counter_Treaty_Changes                 := -2
  set lng_AI_Anger_Amount_Msg_Break_Treaty                           := 15
  set lng_AI_Anger_Amount_Msg_Propose_Trade                          := -3
  set lng_AI_Anger_Amount_Msg_Accept_Trade                           := -5
  set lng_AI_Anger_Amount_Msg_Refuse_Trade                           := 3
  set lng_AI_Anger_Amount_Msg_Counter_Trade                          := -2
  set lng_AI_Anger_Amount_Msg_Request_Gift                           := 5
  set lng_AI_Anger_Amount_Msg_Give_Gift                              := -5
  set lng_AI_Anger_Amount_Msg_Accept_Gift                            := -5
  set lng_AI_Anger_Amount_Msg_Refuse_Gift                            := 5
  set lng_AI_Anger_Amount_Msg_Request_Accept                         := -5
  set lng_AI_Anger_Amount_Msg_Request_Refuse                         := 5
  set lng_AI_Anger_Amount_Msg_Request_Surrender                      := 15
  set lng_AI_Anger_Amount_Msg_Propose_Alliance                       := -5
  set lng_AI_Anger_Amount_Msg_Accept_Alliance                        := -10
  set lng_AI_Anger_Amount_Msg_Refuse_Alliance                        := 5
  set lng_AI_Anger_Amount_Msg_Leave_Alliance                         := 15

  // Set Cue Cappa anger amounts for ships/units/colonies in their territory
  set lng_AI_Anger_Amount_Ships_In_Territory                         := 2
  set lng_AI_Anger_Amount_Units_In_Territory                         := 5
  set lng_AI_Anger_Amount_Colonies_In_Territory                      := 5

  // Cue Cappa anger values
  call AI_Set_Political_Anger_For_Log_Types()
  call AI_Set_Political_Anger_For_Messages()
  call AI_Set_Political_Anger_For_Wars()

  // Cue Cappa Treaty & Alliance element anger values
  call AI_Set_Political_Treaty_Elements()
  call AI_Set_Political_Alliance_Elements()

  return TRUE
end

//------------------------------------------------------------------------